package com.service.lyxmservice.service.article;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.service.lyxmservice.dao.article.ArticleListDao;
import com.service.lyxmserviceapi.model.ArticleModel;
import com.service.lyxmserviceapi.service.aritcle.ArticleList;

@Service
public class ArticleListServiceImpl implements ArticleList{
	
	@Autowired
	private ArticleListDao articleListDao; 
	
	@Override
	/**
	 * 根基模块id查询文章列表
	 * @param id
	 * @return
	 */
	public List<ArticleModel> getArticleListByModuleId(String id) {
		List<ArticleModel> list = articleListDao.getArticleListByModuleId(id);
		for(ArticleModel ar :list){
			//分割target标签
			if(ar.getTarget()!=""&&ar.getTarget()!=null){
				String []target = ar.getTarget().split(",");
				List<String> targetList = new ArrayList<String>();
				for(int x= 0;x<target.length;x++){
					targetList.add(target[x]);
				}
				ar.setTargetList(targetList);
			}
		}
		return list;
	}

}
